list-[id].vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <section class="book_son_right clearfix">
  13. <div class="book_son_right_ul clearfix">
  14. <div class="book_son_right_li clearfix" v-for="(item, index) in newsDetail" :key="index">
  15. <div class="book_son_right_li_img">
  16. <img class="book_son_right_li_img" :src="item.img_url" :title="item.title"
  17. v-if="item.img_url">
  18. </div>
  19. <div class="book_son_right_li_in clearfix">
  20. <h4 class="book_son_right_li_h4 dot1">{{ item.title }}</h4>
  21. <div class="book_son_right_li_dot3 dot3">
  22. {{ item.description }}
  23. </div>
  24. <NuxtLink :href="`/${item.pinyin}/${item.id}.html`" class="book_son_right_li_btn"
  25. :title="item.name">
  26. 查看详情
  27. </NuxtLink>
  28. </div>
  29. </div>
  30. </div>
  31. </section>
  32. <!-- 分页器 -->
  33. <div class="pagination phone_none" v-if="total > 0">
  34. <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
  35. :page-size="pageSize" prev-text="上一页" next-text="下一页" @change="changePage" />
  36. </div>
  37. </div>
  38. <div class="innerRight">
  39. <div class="rightMenuTitle">
  40. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  41. </div>
  42. <ul>
  43. <li v-for="(item, index) in bottomMenu" :key="index">
  44. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  45. v-if="item.category_id == pageId" class="active">
  46. {{ item.alias }}
  47. </NuxtLink>
  48. <NuxtLink :to="`/${item.pinyin}/list-1.html`" :title="item.name"
  49. v-else-if="item.category_id != pageId">
  50. {{ item.alias }}
  51. </NuxtLink>
  52. </li>
  53. </ul>
  54. </div>
  55. <div style="clear: both;"></div>
  56. </div>
  57. <div class="pagination pc_none" v-if="total > 0">
  58. <el-pagination size="small" background layout=" pager " :total="total" class="mt-4" pager-count="5"
  59. :page-size="pageSize" @change="changePage" />
  60. </div>
  61. </div>
  62. <!-- 广告二 -->
  63. <HomeTopTen :imgurl="adImg2" v-if="adImg2"></HomeTopTen>
  64. <!-- 页面底部 -->
  65. <HomeFoot1></HomeFoot1>
  66. </template>
  67. <script setup>
  68. //1.页面依赖 start ---------------------------------------->
  69. import { ElPagination } from 'element-plus'
  70. import { ArrowRight } from '@element-plus/icons-vue'
  71. import { ref, onMounted } from 'vue';
  72. //获得跳转过来的id
  73. const route = useRoute();
  74. //获得当前的完整路径
  75. const fullPath = route.path;
  76. //拆分,取出来中间这一段,然后提取数字部分
  77. const segments = fullPath.split('/');
  78. const targetSegment = segments[2];
  79. const targetSegment1 = segments[1];
  80. const allSegment = targetSegment1 + '/' + targetSegment;
  81. //const numberPart = targetSegment.match(/\d+$/)?.[0];
  82. let articleId;
  83. let pageId;
  84. let routeId
  85. let activeId = parseInt(route.params.id);
  86. console.log('activeId', activeId);
  87. //通过导航路径反向查询导航id
  88. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  89. method: 'GET',
  90. query: {
  91. 'pinyin': allSegment,
  92. },
  93. });
  94. if (getRouteId.code == 200) {
  95. articleId = getRouteId.data.id;
  96. pageId = getRouteId.data.category_id;
  97. } else {
  98. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  99. console.log("错误位置:通过url路径查询导航池id")
  100. console.log("后端错误反馈:", getRouteId.message)
  101. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  102. }
  103. //通过导航路径反向查询导航id
  104. const getRouteId1 = await requestDataPromise('/web/getWebsiteRoute', {
  105. method: 'GET',
  106. query: {
  107. 'pinyin': targetSegment1,
  108. },
  109. });
  110. if (getRouteId1.code == 200) {
  111. routeId = getRouteId1.data.category_id;
  112. } else {
  113. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  114. console.log("错误位置:通过url路径查询导航池id")
  115. console.log("后端错误反馈:", getRouteId1.message)
  116. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  117. }
  118. //面包屑导航
  119. const parent_name = ref("");
  120. const parent_id = ref("");
  121. const parent_pinyin = ref("");
  122. let getParentNav = async () => {
  123. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  124. method: 'GET',
  125. query: {
  126. 'catid': routeId,
  127. },
  128. });
  129. if (listData.code == 200) {
  130. parent_name.value = listData.data.alias;
  131. parent_id.value = listData.data.parent_id;
  132. parent_pinyin.value = listData.data.aLIas_pinyin;
  133. } else {
  134. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  135. console.log("错误位置:获取面包屑导航")
  136. console.log("后端错误反馈:", listData.message)
  137. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  138. }
  139. }
  140. //获得父级栏目详情
  141. getParentNav();
  142. //1.页面依赖 end ---------------------------------------->
  143. //2.页面数据 start ---------------------------------------->
  144. //广告列表
  145. const adList = ref([]);
  146. let adImg1 = ref([]);
  147. let adImg2 = ref([]);
  148. async function getAdData() {
  149. const adData = await requestDataPromise('/web/getWebsiteAdvertisement', { method: 'GET', query: { 'ad_tag': 'PAGE' } });
  150. adList.value = adData.data;
  151. if (adData.code == 200) {
  152. for (let item of adData.data) {
  153. if (item.ad_tag == 'PAGE_0001') {
  154. adImg1.value = item;
  155. }
  156. if (item.ad_tag == 'PAGE_0002') {
  157. adImg2.value = item;
  158. }
  159. }
  160. } else {
  161. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  162. console.log("错误位置:获取详情页广告列表")
  163. console.log("后端错误反馈:", adData.message)
  164. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  165. }
  166. }
  167. getAdData();
  168. const newsDetail = ref({})
  169. const bottomMenu = ref([]);
  170. const seoTitle = ref('');//
  171. const total = ref(0);//总条数
  172. const page = ref(1);//当前页码
  173. const pageSize = ref(10); //每页显示的条数
  174. const mkdata = await requestDataPromise('/web/getWebsiteBookList', {
  175. method: 'GET',
  176. query: {
  177. 'id': pageId,
  178. 'page': page.value,
  179. 'pageSize': pageSize.value,
  180. },
  181. });
  182. for(let item of mkdata.data.category){
  183. if(item.category_id == pageId){
  184. seoTitle.value = item.alias;
  185. }
  186. }
  187. bottomMenu.value = mkdata.data.category;
  188. newsDetail.value = mkdata.data.books;
  189. total.value = mkdata.data.count;
  190. //2.页面数据 end ---------------------------------------->
  191. //3.分页器 start ---------------------------------------->
  192. //分页事件
  193. let changePage = (value) => {
  194. console.log("当前页码", value);
  195. page.value = value;
  196. getPageMenu()
  197. }
  198. //3.分页器 end ---------------------------------------->
  199. //4.设置seo信息 start---------------------------------------->
  200. //4.1 设置seo信息
  201. const setData = await requestDataPromise('/web/getWebsiteFootInfo', {
  202. method: 'GET',
  203. query: {},
  204. });
  205. console.log(123)
  206. console.log(seoTitle.value)
  207. //let seoTitle = setData.data.website_head.title;
  208. let seoDescription = setData.data.website_head.description;
  209. let seoKeywords = setData.data.website_head.keywords;
  210. let seoSuffix = setData.data.website_head.suffix;
  211. let seoName = setData.data.website_head.website_name;
  212. useSeoMeta({
  213. title: seoTitle.value + "_" + seoSuffix,
  214. meta: [
  215. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  216. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  217. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  218. ]
  219. });
  220. //4.设置seo信息 end---------------------------------------->
  221. onMounted(async () => {
  222. //从客户端获取行政职能部门 加快打开速度
  223. const { $webUrl, $CwebUrl } = useNuxtApp();
  224. //广告1
  225. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_list_0001`
  226. const responseAd1 = await fetch(url, {
  227. headers: {
  228. 'Content-Type': 'application/json',
  229. 'Userurl': $CwebUrl,
  230. 'Origin': $CwebUrl
  231. }
  232. });
  233. const resultAd1 = await responseAd1.json();
  234. adImg1.value = resultAd1.data[0];
  235. //广告2
  236. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=nzgxw_list_0002`
  237. const responseAd2 = await fetch(url2, {
  238. headers: {
  239. 'Content-Type': 'application/json',
  240. 'Userurl': $CwebUrl,
  241. 'Origin': $CwebUrl
  242. }
  243. });
  244. const resultAd2 = await responseAd2.json();
  245. adImg2.value = resultAd2.data[0];
  246. })
  247. </script>
  248. <style lang="less" scoped>
  249. @import '@/assets/css/shukanList.less';
  250. </style>
  251. <style lang="less" scoped>
  252. @media screen and (min-width:801px){/*pc*/
  253. .pc_none{display:none;}
  254. }
  255. @media screen and (max-width:800px){/*ipad_phone*/
  256. .newsDetail {margin-top:11px;}
  257. .newsDetail .inner{width:92%;margin:0px auto 11px;overflow:hidden;}
  258. .newsDetail .inner .innerRight{width:24%; }
  259. .newsDetail .inner .innerRight .rightMenuTitle{width:100%;height:auto; background-size:100% 155%; margin-bottom:11px;}
  260. .newsDetail .inner .innerRight .rightMenuTitle a{display:block;width:100%;height:auto;line-height:33px;font-size:14px;text-align:center;}
  261. .newsDetail .inner .innerRight ul{display:block;width:100%;height:auto;}
  262. .newsDetail .inner .innerRight ul li{display:block;width:100%;height:auto;}
  263. .newsDetail .inner .innerRight ul li a {line-height:20px;height:auto;font-size:12px;margin-bottom:5px;padding: 6px 2px;box-sizing:border-box;
  264. border-left: 2px solid #a91b33;}
  265. .newsDetail .inner .innerLeft{width:72%;overflow:hidden;margin:0 ;}
  266. .newsDetail .inner .innerLeft .book_son_right{float:none;width:100%;overflow:hidden;margin-bottom:22px;min-height:auto;}
  267. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li>.book_son_right_li_img{width:30%;margin-right:4%;height:auto;}
  268. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li>.book_son_right_li_img .book_son_right_li_img{width:100%;height:27vw; }
  269. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_in{width:auto;float:none; }
  270. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_h4{margin-top:0px;font-size:14px;
  271. line-height:20px;
  272. height:40px;
  273. word-break: normal;
  274. white-space: break-spaces;
  275. overflow: hidden;
  276. text-overflow: unset;
  277. display:-webkit-box!important;-webkit-box-orient:vertical;-webkit-line-clamp:2;
  278. }
  279. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_dot3{line-height:20px;height:40px;font-size:14px;-webkit-line-clamp:2;display:none;}
  280. .newsDetail .inner .innerLeft .book_son_right_ul .book_son_right_li_btn{
  281. padding:0px 8px;margin-top:8px;height:28px;line-height:28px;font-size:12px;
  282. position:absolute;bottom:0px;left:37%;
  283. }
  284. .newsDetail{margin-bottom:11px;}
  285. .pagination{margin-top:11px;}
  286. .book_son_right_ul{min-height:540px;}
  287. .part_2{height:11px;}
  288. .phone_none{display:none;}
  289. }
  290. </style>